package com.fourth_groups.shopping121store.ui.category.adapter.commonadapter;

import android.support.v4.view.PagerAdapter;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2016/9/10.
 */
public class ShowImgPagerAdapter extends PagerAdapter{
    private List<ImageView> images = new ArrayList<>();

    public ShowImgPagerAdapter(List<ImageView> images) {
        this.images= images;
    }

    @Override
    public int getCount() {
        return Integer.MAX_VALUE;
    }

    @Override
    public Object instantiateItem(ViewGroup container, int position) {
        container.addView(images.get(position % images.size()));
        return images.get(position % images.size());
    }

    @Override
    public boolean isViewFromObject(View view, Object object) {
        return view == object;
    }

    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {
        //从容器中移除某个条目
        container.removeView(images.get(position % images.size()));
    }
}
